//
//  BHFunApplyAddressCell.swift
//  BigHealth
//
//  Created by 蔺百好 on 2021/6/24.
//

import UIKit

class BHFunApplyAddressCell: UITableViewCell {

    @IBOutlet weak var choseAddressBtn: UIButton!
    
    @IBOutlet weak var addressView: UIView!
    
    @IBOutlet weak var iconImgView: UIImageView!
    
    @IBOutlet weak var name_label: UILabel!
    
    @IBOutlet weak var area_label: UILabel!
    
    @IBOutlet weak var name_leading: NSLayoutConstraint!
    
    var haveAddress: Bool = false {
        didSet {
            self.addressView.isHidden = !haveAddress
        }
    }
    
    var model: BHFunPublishRelateModel? {
        didSet {
            self.choseAddressBtn.isSelected = model != nil
            if model == nil {
                self.choseAddressBtn.setTitle("请选择活动地址", for: .normal)
                return
            }
            self.choseAddressBtn.setTitle("修改", for: .selected)

            self.iconImgView.sd_setImage(with: URL.init(string: model!.relationPic), completed: nil)
            self.name_label.text = model?.relationName
            self.area_label.text = "\(model?.cityName ?? "") / \(model?.areaName ?? "")"
        }
    }
    
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    static func cellHeightWithAddress(haveAddress: Bool) -> CGFloat {
        if haveAddress == true {
            return 150
        }else {
            return 50
        }
    }
    
}
